home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / flames.zip / WEAPONS.QC < prev    next >
Text File  |  1996-09-14  |  31KB  |  1,350 lines

  1. /*
  2. WEAPONS
  3. */
  4. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  5. void () player_run;
  6. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  7. void(vector org, vector vel, float damage) SpawnBlood;
  8. void() SuperDamageSound;
  9.  
  10. //========================================================================
  11. //========================================================================
  12.  
  13. // called by worldspawn
  14. void() W_Precache =
  15. {
  16.     precache_sound ("weapons/r_exp3.wav");    // new rocket explosion
  17.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  18.     precache_sound ("weapons/sgun1.wav");
  19.     precache_sound ("weapons/guncock.wav");    // player shotgun
  20.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  21.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  22.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  23.     precache_sound ("weapons/spike2.wav");    // super spikes
  24.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  25.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  26.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  27.     precache_sound ("weapons/shotgn2.wav");    // super shotgun
  28. };
  29.  
  30. float() crandom =
  31. {
  32.     return 2*(random() - 0.5);
  33. };
  34.  
  35. /*
  36. ================
  37. W_FireAxe
  38. ================
  39. */
  40. void() W_FireAxe =
  41. {
  42.     local    vector    source;
  43.     local    vector    org;
  44.  
  45.     source = self.origin + '0 0 16';
  46.     traceline (source, source + v_forward*64, FALSE, self);
  47.     if (trace_fraction == 1.0)
  48.         return;
  49.     
  50.     org = trace_endpos - v_forward*4;
  51.  
  52.     if (trace_ent.takedamage)
  53.     {
  54.         trace_ent.axhitme = 1;
  55.         SpawnBlood (org, '0 0 0', 20);
  56.         T_Damage (trace_ent, self, self, 20);
  57.     }
  58.     else
  59.     {    // hit wall
  60.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  61.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  62.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  63.         WriteCoord (MSG_BROADCAST, org_x);
  64.         WriteCoord (MSG_BROADCAST, org_y);
  65.         WriteCoord (MSG_BROADCAST, org_z);
  66.     }
  67. };
  68.  
  69.  
  70. //============================================================================
  71.  
  72.  
  73. vector() wall_velocity =
  74. {
  75.     local vector    vel;
  76.     
  77.     vel = normalize (self.velocity);
  78.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  79.     vel = vel + 2*trace_plane_normal;
  80.     vel = vel * 200;
  81.     
  82.     return vel;
  83. };
  84.  
  85.  
  86. /*
  87. ================
  88. SpawnMeatSpray
  89. ================
  90. */
  91. void(vector org, vector vel) SpawnMeatSpray =
  92. {
  93.     local    entity missile, mpuff;
  94.     local    vector    org;
  95.  
  96.     missile = spawn ();
  97.     missile.owner = self;
  98.     missile.movetype = MOVETYPE_BOUNCE;
  99.     missile.solid = SOLID_NOT;
  100.  
  101.     makevectors (self.angles);
  102.  
  103.     missile.velocity = vel;
  104.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  105.  
  106.     missile.avelocity = '3000 1000 2000';
  107.     
  108. // set missile duration
  109.     missile.nextthink = time + 1;
  110.     missile.think = SUB_Remove;
  111.  
  112.     setmodel (missile, "progs/zom_gib.mdl");
  113.     setsize (missile, '0 0 0', '0 0 0');        
  114.     setorigin (missile, org);
  115. };
  116.  
  117. /*
  118. ================
  119. SpawnBlood
  120. ================
  121. */
  122. void(vector org, vector vel, float damage) SpawnBlood =
  123. {
  124.     particle (org, vel*0.1, 73, damage*2);
  125. };
  126.  
  127. /*
  128. ================
  129. spawn_touchblood
  130. ================
  131. */
  132. void(float damage) spawn_touchblood =
  133. {
  134.     local vector    vel;
  135.  
  136.     vel = wall_velocity () * 0.2;
  137.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  138. };
  139.  
  140.  
  141. /*
  142. ================
  143. SpawnChunk
  144. ================
  145. */
  146. void(vector org, vector vel) SpawnChunk =
  147. {
  148.     particle (org, vel*0.02, 0, 10);
  149. };
  150.  
  151. /*
  152. ==============================================================================
  153.  
  154. MULTI-DAMAGE
  155.  
  156. Collects multiple small damages into a single damage
  157.  
  158. ==============================================================================
  159. */
  160.  
  161. entity    multi_ent;
  162. float    multi_damage;
  163.  
  164. void() ClearMultiDamage =
  165. {
  166.     multi_ent = world;
  167.     multi_damage = 0;
  168. };
  169.  
  170. void() ApplyMultiDamage =
  171. {
  172.     if (!multi_ent)
  173.         return;
  174.     T_Damage (multi_ent, self, self, multi_damage);
  175. };
  176.  
  177. void(entity hit, float damage) AddMultiDamage =
  178. {
  179.     if (!hit)
  180.         return;
  181.     
  182.     if (hit != multi_ent)
  183.     {
  184.         ApplyMultiDamage ();
  185.         multi_damage = damage;
  186.         multi_ent = hit;
  187.     }
  188.     else
  189.         multi_damage = multi_damage + damage;
  190. };
  191.  
  192. /*
  193. ==============================================================================
  194.  
  195. BULLETS
  196.  
  197. ==============================================================================
  198. */
  199.  
  200. /*
  201. ================
  202. TraceAttack
  203. ================
  204. */
  205. void(float damage, vector dir) TraceAttack =
  206. {
  207.     local    vector    vel, org;
  208.     
  209.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  210.     vel = vel + 2*trace_plane_normal;
  211.     vel = vel * 200;
  212.  
  213.     org = trace_endpos - dir*4;
  214.  
  215.     if (trace_ent.takedamage)
  216.     {
  217.         SpawnBlood (org, vel*0.2, damage);
  218.         AddMultiDamage (trace_ent, damage);
  219.     }
  220.     else
  221.     {
  222.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  223.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  224.         WriteCoord (MSG_BROADCAST, org_x);
  225.         WriteCoord (MSG_BROADCAST, org_y);
  226.         WriteCoord (MSG_BROADCAST, org_z);
  227.     }
  228. };
  229.  
  230. /*
  231. ================
  232. FireBullets
  233.  
  234. Used by shotgun, super shotgun, and enemy soldier firing
  235. Go to the trouble of combining multiple pellets into a single damage call.
  236. ================
  237. */
  238. void(float shotcount, vector dir, vector spread) FireBullets =
  239. {
  240.     local    vector direction;
  241.     local    vector    src;
  242.     
  243.     makevectors(self.v_angle);
  244.  
  245.     src = self.origin + v_forward*10;
  246.     src_z = self.absmin_z + self.size_z * 0.7;
  247.  
  248.     ClearMultiDamage ();
  249.     while (shotcount > 0)
  250.     {
  251.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  252.  
  253.         traceline (src, src + direction*2048, FALSE, self);
  254.         if (trace_fraction != 1.0)
  255.             TraceAttack (4, direction);
  256.  
  257.         shotcount = shotcount - 1;
  258.     }
  259.     ApplyMultiDamage ();
  260. };
  261.  
  262. /*
  263. ================
  264. W_FireShotgun
  265. ================
  266. */
  267. void() W_FireShotgun =
  268. {
  269.     local vector dir;
  270.  
  271.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);    
  272.  
  273.     self.punchangle_x = -2;
  274.     
  275.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  276.     dir = aim (self, 100000);
  277.     FireBullets (6, dir, '0.04 0.04 0');
  278. };
  279.  
  280.  
  281. /*
  282. ================
  283. W_FireSuperShotgun
  284. ================
  285. */
  286. void() W_FireSuperShotgun =
  287. {
  288.     local vector dir;
  289.  
  290.     if (self.currentammo == 1)
  291.     {
  292.         W_FireShotgun ();
  293.         return;
  294.     }
  295.         
  296.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  297.  
  298.     self.punchangle_x = -4;
  299.     
  300.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  301.     dir = aim (self, 100000);
  302.     FireBullets (14, dir, '0.14 0.08 0');
  303. };
  304.  
  305.  
  306. /*
  307. ==============================================================================
  308.  
  309. ROCKETS
  310.  
  311. ==============================================================================
  312. */
  313.  
  314. void()    s_explode1    =    [0,        s_explode2] {};
  315. void()    s_explode2    =    [1,        s_explode3] {};
  316. void()    s_explode3    =    [2,        s_explode4] {};
  317. void()    s_explode4    =    [3,        s_explode5] {};
  318. void()    s_explode5    =    [4,        s_explode6] {};
  319. void()    s_explode6    =    [5,        SUB_Remove] {};
  320.  
  321. void() BecomeExplosion =
  322. {
  323.     self.movetype = MOVETYPE_NONE;
  324.     self.velocity = '0 0 0';
  325.     self.touch = SUB_Null;
  326.     setmodel (self, "progs/s_explod.spr");
  327.     self.solid = SOLID_NOT;
  328.     s_explode1 ();
  329. //================================================
  330. //              START FLAMES
  331. //================================================
  332.         Flame_Ignite();
  333.         Flame_Ignite();
  334.         if (random() < 0.5)
  335.                 Flame_Ignite();
  336. //================================================
  337. //              END FLAMES
  338. //================================================
  339. };
  340.  
  341. void() T_MissileTouch =
  342. {
  343.     local float    damg;
  344.  
  345.     if (other == self.owner)
  346.         return;        // don't explode on owner
  347.  
  348.     if (pointcontents(self.origin) == CONTENT_SKY)
  349.     {
  350.         remove(self);
  351.         return;
  352.     }
  353.  
  354.     damg = 100 + random()*20;
  355.     
  356.     if (other.health)
  357.     {
  358.         if (other.classname == "monster_shambler")
  359.             damg = damg * 0.5;    // mostly immune
  360.         T_Damage (other, self, self.owner, damg );
  361.     }
  362.  
  363.     // don't do radius damage to the other, because all the damage
  364.     // was done in the impact
  365.     T_RadiusDamage (self, self.owner, 120, other);
  366.  
  367. //    sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  368.     self.origin = self.origin - 8*normalize(self.velocity);
  369.  
  370.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  371.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  372.     WriteCoord (MSG_BROADCAST, self.origin_x);
  373.     WriteCoord (MSG_BROADCAST, self.origin_y);
  374.     WriteCoord (MSG_BROADCAST, self.origin_z);
  375.  
  376.     BecomeExplosion ();
  377. };
  378.  
  379.  
  380.  
  381. /*
  382. ================
  383. W_FireRocket
  384. ================
  385. */
  386. void() W_FireRocket =
  387. {
  388.     local    entity missile, mpuff;
  389.     
  390.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  391.     
  392.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  393.  
  394.     self.punchangle_x = -2;
  395.  
  396.     missile = spawn ();
  397.     missile.owner = self;
  398.     missile.movetype = MOVETYPE_FLYMISSILE;
  399.     missile.solid = SOLID_BBOX;
  400.         
  401. // set missile speed    
  402.  
  403.     makevectors (self.v_angle);
  404.     missile.velocity = aim(self, 1000);
  405.     missile.velocity = missile.velocity * 1000;
  406.     missile.angles = vectoangles(missile.velocity);
  407.     
  408.     missile.touch = T_MissileTouch;
  409.     
  410. // set missile duration
  411.     missile.nextthink = time + 5;
  412.     missile.think = SUB_Remove;
  413.  
  414.     setmodel (missile, "progs/missile.mdl");
  415.     setsize (missile, '0 0 0', '0 0 0');        
  416.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  417. };
  418.  
  419. /*
  420. ===============================================================================
  421.  
  422. LIGHTNING
  423.  
  424. ===============================================================================
  425. */
  426.  
  427. /*
  428. =================
  429. LightningDamage
  430. =================
  431. */
  432. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  433. {
  434.     local entity        e1, e2;
  435.     local vector        f;
  436.     
  437.     f = p2 - p1;
  438.     normalize (f);
  439.     f_x = 0 - f_y;
  440.     f_y = f_x;
  441.     f_z = 0;
  442.     f = f*16;
  443.  
  444.     e1 = e2 = world;
  445.  
  446.     traceline (p1, p2, FALSE, self);
  447.     if (trace_ent.takedamage)
  448.     {
  449.         particle (trace_endpos, '0 0 100', 225, damage*4);
  450.         T_Damage (trace_ent, from, from, damage);
  451.         if (self.classname == "player")
  452.         {
  453.             if (other.classname == "player")
  454.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  455.         }
  456.     }
  457.     e1 = trace_ent;
  458.  
  459.     traceline (p1 + f, p2 + f, FALSE, self);
  460.     if (trace_ent != e1 && trace_ent.takedamage)
  461.     {
  462.         particle (trace_endpos, '0 0 100', 225, damage*4);
  463.         T_Damage (trace_ent, from, from, damage);
  464.     }
  465.     e2 = trace_ent;
  466.  
  467.     traceline (p1 - f, p2 - f, FALSE, self);
  468.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  469.     {
  470.         particle (trace_endpos, '0 0 100', 225, damage*4);
  471.         T_Damage (trace_ent, from, from, damage);
  472.     }
  473. };
  474.  
  475.  
  476. void() W_FireLightning =
  477. {
  478.     local    vector        org;
  479.  
  480.     if (self.ammo_cells < 1)
  481.     {
  482.         self.weapon = W_BestWeapon ();
  483.         W_SetCurrentAmmo ();
  484.         return;
  485.     }
  486.  
  487. // explode if under water
  488.     if (self.waterlevel > 1)
  489.     {
  490.         T_RadiusDamage (self, self, 35*self.ammo_cells, world);
  491.         self.ammo_cells = 0;
  492.         W_SetCurrentAmmo ();
  493.         return;
  494.     }
  495.  
  496.     if (self.t_width < time)
  497.     {
  498.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  499.         self.t_width = time + 0.6;
  500.     }
  501.     self.punchangle_x = -2;
  502.  
  503.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  504.  
  505.     org = self.origin + '0 0 16';
  506.     
  507.     traceline (org, org + v_forward*600, TRUE, self);
  508.  
  509.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  510.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  511.     WriteEntity (MSG_BROADCAST, self);
  512.     WriteCoord (MSG_BROADCAST, org_x);
  513.     WriteCoord (MSG_BROADCAST, org_y);
  514.     WriteCoord (MSG_BROADCAST, org_z);
  515.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  516.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  517.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  518.  
  519.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  520. };
  521.  
  522.  
  523. //=============================================================================
  524.  
  525.  
  526. void() GrenadeExplode =
  527. {
  528.     T_RadiusDamage (self, self.owner, 120, world);
  529.  
  530.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  531.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  532.     WriteCoord (MSG_BROADCAST, self.origin_x);
  533.     WriteCoord (MSG_BROADCAST, self.origin_y);
  534.     WriteCoord (MSG_BROADCAST, self.origin_z);
  535.  
  536.  
  537.     BecomeExplosion ();
  538. };
  539.  
  540. void() GrenadeTouch =
  541. {
  542.     if (other == self.owner)
  543.         return;        // don't explode on owner
  544.     if (other.takedamage == DAMAGE_AIM)
  545.     {
  546.         GrenadeExplode();
  547.         return;
  548.     }
  549.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  550.     if (self.velocity == '0 0 0')
  551.         self.avelocity = '0 0 0';
  552. };
  553.  
  554. /*
  555. ================
  556. W_FireGrenade
  557. ================
  558. */
  559. void() W_FireGrenade =
  560. {
  561.     local    entity missile, mpuff;
  562.     
  563.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  564.     
  565.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  566.  
  567.     self.punchangle_x = -2;
  568.  
  569.     missile = spawn ();
  570.     missile.owner = self;
  571.     missile.movetype = MOVETYPE_BOUNCE;
  572.     missile.solid = SOLID_BBOX;
  573.     missile.classname = "grenade";
  574.  
  575. //        missile.effects = EF_BRIGHTLIGHT;
  576. // set missile speed    
  577.  
  578.     makevectors (self.v_angle);
  579.  
  580.     if (self.v_angle_x)
  581.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  582.     else
  583.     {
  584.         missile.velocity = aim(self, 10000);
  585.         missile.velocity = missile.velocity * 600;
  586.         missile.velocity_z = 200;
  587.     }
  588.  
  589.     missile.avelocity = '300 300 300';
  590.  
  591.     missile.angles = vectoangles(missile.velocity);
  592.     
  593.     missile.touch = GrenadeTouch;
  594.     
  595. // set missile duration
  596.     missile.nextthink = time + 2.5;
  597.     missile.think = GrenadeExplode;
  598.  
  599.     setmodel (missile, "progs/grenade.mdl");
  600.     setsize (missile, '0 0 0', '0 0 0');        
  601.     setorigin (missile, self.origin);
  602.  
  603. //        W_FireFlare;
  604. };
  605.  
  606.  
  607. //=============================================================================
  608.  
  609. void() spike_touch;
  610. void() superspike_touch;
  611.  
  612.  
  613. /*
  614. ===============
  615. launch_spike
  616.  
  617. Used for both the player and the ogre
  618. ===============
  619. */
  620. void(vector org, vector dir) launch_spike =
  621. {
  622.     newmis = spawn ();
  623.     newmis.owner = self;
  624.     newmis.movetype = MOVETYPE_FLYMISSILE;
  625.     newmis.solid = SOLID_BBOX;
  626.  
  627.     newmis.angles = vectoangles(dir);
  628.     
  629.     newmis.touch = spike_touch;
  630.     newmis.classname = "spike";
  631.     newmis.think = SUB_Remove;
  632.     newmis.nextthink = time + 6;
  633.     setmodel (newmis, "progs/spike.mdl");
  634.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  635.     setorigin (newmis, org);
  636.  
  637.     newmis.velocity = dir * 1000;
  638. };
  639.  
  640. void() W_FireSuperSpikes =
  641. {
  642.     local vector    dir;
  643.     local entity    old;
  644.     
  645.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  646.     self.attack_finished = time + 0.2;
  647.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  648.     dir = aim (self, 1000);
  649.     launch_spike (self.origin + '0 0 16', dir);
  650.     newmis.touch = superspike_touch;
  651.     setmodel (newmis, "progs/s_spike.mdl");
  652.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  653.     self.punchangle_x = -2;
  654. };
  655.  
  656. void(float ox) W_FireSpikes =
  657. {
  658.     local vector    dir;
  659.     local entity    old;
  660.     
  661.     makevectors (self.v_angle);
  662.     
  663.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  664.     {
  665.         W_FireSuperSpikes ();
  666.         return;
  667.     }
  668.  
  669.     if (self.ammo_nails < 1)
  670.     {
  671.         self.weapon = W_BestWeapon ();
  672.         W_SetCurrentAmmo ();
  673.         return;
  674.     }
  675.  
  676.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  677.     self.attack_finished = time + 0.2;
  678.     self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  679.     dir = aim (self, 1000);
  680.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  681.  
  682.     self.punchangle_x = -2;
  683. };
  684.  
  685.  
  686.  
  687. .float hit_z;
  688. void() spike_touch =
  689. {
  690. local float rand;
  691.     if (other == self.owner)
  692.         return;
  693.  
  694.     if (other.solid == SOLID_TRIGGER)
  695.         return;    // trigger field, do nothing
  696.  
  697.     if (pointcontents(self.origin) == CONTENT_SKY)
  698.     {
  699.         remove(self);
  700.         return;
  701.     }
  702.     
  703. // hit something that bleeds
  704.     if (other.takedamage)
  705.     {
  706.         spawn_touchblood (9);
  707.         T_Damage (other, self, self.owner, 9);
  708.     }
  709.     else
  710.     {
  711.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  712.         
  713.         if (self.classname == "wizspike")
  714.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  715.         else if (self.classname == "knightspike")
  716.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  717.         else
  718.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  719.         WriteCoord (MSG_BROADCAST, self.origin_x);
  720.         WriteCoord (MSG_BROADCAST, self.origin_y);
  721.         WriteCoord (MSG_BROADCAST, self.origin_z);
  722.     }
  723.  
  724.     remove(self);
  725.  
  726. };
  727.  
  728. void() superspike_touch =
  729. {
  730. local float rand;
  731.     if (other == self.owner)
  732.         return;
  733.  
  734.     if (other.solid == SOLID_TRIGGER)
  735.         return;    // trigger field, do nothing
  736.  
  737.     if (pointcontents(self.origin) == CONTENT_SKY)
  738.     {
  739.         remove(self);
  740.         return;
  741.     }
  742.     
  743. // hit something that bleeds
  744.     if (other.takedamage)
  745.     {
  746.         spawn_touchblood (18);
  747.         T_Damage (other, self, self.owner, 18);
  748.     }
  749.     else
  750.     {
  751.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  752.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  753.         WriteCoord (MSG_BROADCAST, self.origin_x);
  754.         WriteCoord (MSG_BROADCAST, self.origin_y);
  755.         WriteCoord (MSG_BROADCAST, self.origin_z);
  756.     }
  757.  
  758.     remove(self);
  759.  
  760. };
  761.  
  762.  
  763. /*
  764. ===============================================================================
  765.  
  766. PLAYER WEAPON USE
  767.  
  768. ===============================================================================
  769. */
  770.  
  771. void() W_SetCurrentAmmo =
  772. {
  773.     player_run ();        // get out of any weapon firing states
  774.  
  775.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  776.     
  777.     if (self.weapon == IT_AXE)
  778.     {
  779.         self.currentammo = 0;
  780.         self.weaponmodel = "progs/v_axe.mdl";
  781.         self.weaponframe = 0;
  782.     }
  783.     else if (self.weapon == IT_SHOTGUN)
  784.     {
  785.         self.currentammo = self.ammo_shells;
  786.         self.weaponmodel = "progs/v_shot.mdl";
  787.         self.weaponframe = 0;
  788.         self.items = self.items | IT_SHELLS;
  789.     }
  790.     else if (self.weapon == IT_SUPER_SHOTGUN)
  791.     {
  792.         self.currentammo = self.ammo_shells;
  793.         self.weaponmodel = "progs/v_shot2.mdl";
  794.         self.weaponframe = 0;
  795.         self.items = self.items | IT_SHELLS;
  796.     }
  797.     else if (self.weapon == IT_NAILGUN)
  798.     {
  799.         self.currentammo = self.ammo_nails;
  800.         self.weaponmodel = "progs/v_nail.mdl";
  801.         self.weaponframe = 0;
  802.         self.items = self.items | IT_NAILS;
  803.     }
  804.     else if (self.weapon == IT_SUPER_NAILGUN)
  805.     {
  806.         self.currentammo = self.ammo_nails;
  807.         self.weaponmodel = "progs/v_nail2.mdl";
  808.         self.weaponframe = 0;
  809.         self.items = self.items | IT_NAILS;
  810.     }
  811.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  812.     {
  813.         self.currentammo = self.ammo_rockets;
  814.         self.weaponmodel = "progs/v_rock.mdl";
  815.         self.weaponframe = 0;
  816.         self.items = self.items | IT_ROCKETS;
  817.     }
  818.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  819.     {
  820.         self.currentammo = self.ammo_rockets;
  821.         self.weaponmodel = "progs/v_rock2.mdl";
  822.         self.weaponframe = 0;
  823.         self.items = self.items | IT_ROCKETS;
  824.     }
  825.     else if (self.weapon == IT_LIGHTNING)
  826.     {
  827.         self.currentammo = self.ammo_cells;
  828.         self.weaponmodel = "progs/v_light.mdl";
  829.         self.weaponframe = 0;
  830.         self.items = self.items | IT_CELLS;
  831.     }
  832.         else if (self.weapon == IT_FLARE)
  833.         {
  834.                 self.currentammo = self.ammo_rockets;
  835.                 self.weaponmodel = "progs/v_rock.mdl";
  836.                 self.weaponframe = 0;
  837.                 self.items = self.items | IT_ROCKETS;
  838.         }
  839.     else
  840.     {
  841.         self.currentammo = 0;
  842.         self.weaponmodel = "";
  843.         self.weaponframe = 0;
  844.     }
  845. };
  846.  
  847. float() W_BestWeapon =
  848. {
  849.     local    float    it;
  850.     
  851.     it = self.items;
  852.  
  853.     if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  854.         return IT_LIGHTNING;
  855.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  856.         return IT_SUPER_NAILGUN;
  857.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  858.         return IT_SUPER_SHOTGUN;
  859.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  860.         return IT_NAILGUN;
  861.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  862.         return IT_SHOTGUN;
  863.  
  864.  
  865. /*
  866.     if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
  867.         return IT_ROCKET_LAUNCHER;
  868.     else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
  869.         return IT_GRENADE_LAUNCHER;
  870.  
  871. */
  872.  
  873.     return IT_AXE;
  874. };
  875.  
  876. float() W_CheckNoAmmo =
  877. {
  878.     if (self.currentammo > 0)
  879.         return TRUE;
  880.  
  881.     if (self.weapon == IT_AXE)
  882.         return TRUE;
  883.     
  884.     self.weapon = W_BestWeapon ();
  885.  
  886.     W_SetCurrentAmmo ();
  887.     
  888. // drop the weapon down
  889.     return FALSE;
  890. };
  891.  
  892. /*
  893. ============
  894. W_Attack
  895.  
  896. An attack impulse can be triggered now
  897. ============
  898. */
  899. void()    player_axe1;
  900. void()    player_axeb1;
  901. void()    player_axec1;
  902. void()    player_axed1;
  903. void()    player_shot1;
  904. void()    player_nail1;
  905. void()    player_light1;
  906. void()    player_rocket1;
  907.  
  908. void() W_Attack =
  909. {
  910.     local    float    r;
  911.  
  912.     if (!W_CheckNoAmmo ())
  913.         return;
  914.  
  915.     makevectors    (self.v_angle);            // calculate forward angle for velocity
  916.     self.show_hostile = time + 1;    // wake monsters up
  917.  
  918.     if (self.weapon == IT_AXE)
  919.     {
  920.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  921.         r = random();
  922.         if (r < 0.25)
  923.             player_axe1 ();
  924.         else if (r<0.5)
  925.             player_axeb1 ();
  926.         else if (r<0.75)
  927.             player_axec1 ();
  928.         else
  929.             player_axed1 ();
  930.         self.attack_finished = time + 0.5;
  931.     }
  932.     else if (self.weapon == IT_SHOTGUN)
  933.     {
  934.         player_shot1 ();
  935.         W_FireShotgun ();
  936.         self.attack_finished = time + 0.5;
  937.     }
  938.     else if (self.weapon == IT_SUPER_SHOTGUN)
  939.     {
  940.         player_shot1 ();
  941.         W_FireSuperShotgun ();
  942.         self.attack_finished = time + 0.7;
  943.     }
  944.     else if (self.weapon == IT_NAILGUN)
  945.     {
  946.         player_nail1 ();
  947.     }
  948.     else if (self.weapon == IT_SUPER_NAILGUN)
  949.     {
  950.         player_nail1 ();
  951.     }
  952.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  953.     {
  954.         player_rocket1();
  955.         W_FireGrenade();
  956.         self.attack_finished = time + 0.6;
  957.     }
  958.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  959.     {
  960.         player_rocket1();
  961.         W_FireRocket();
  962.         self.attack_finished = time + 0.8;
  963.     }
  964.     else if (self.weapon == IT_LIGHTNING)
  965.     {
  966.         player_light1();
  967.         self.attack_finished = time + 0.1;
  968.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  969.     }
  970.  
  971. //========================================================================
  972. //                              FLARE START
  973. //========================================================================
  974.         else if (self.weapon == IT_FLARE)
  975.         {
  976.                 player_rocket1();
  977.                 W_FireFlare();
  978.                 self.attack_finished = time + 0.6;
  979.         }
  980. //========================================================================
  981. //                              FLARE END
  982. //========================================================================
  983. };
  984.  
  985. /*
  986. ============
  987. W_ChangeWeapon
  988.  
  989. ============
  990. */
  991. void() W_ChangeWeapon =
  992. {
  993.     local    float    it, am, fl;
  994.     
  995.     it = self.items;
  996.     am = 0;
  997.     
  998.     if (self.impulse == 1)
  999.     {
  1000.         fl = IT_AXE;
  1001.     }
  1002.     else if (self.impulse == 2)
  1003.     {
  1004.         fl = IT_SHOTGUN;
  1005.         if (self.ammo_shells < 1)
  1006.             am = 1;
  1007.     }
  1008.     else if (self.impulse == 3)
  1009.     {
  1010.         fl = IT_SUPER_SHOTGUN;
  1011.         if (self.ammo_shells < 2)
  1012.             am = 1;
  1013.     }        
  1014.     else if (self.impulse == 4)
  1015.     {
  1016.         fl = IT_NAILGUN;
  1017.         if (self.ammo_nails < 1)
  1018.             am = 1;
  1019.     }
  1020.     else if (self.impulse == 5)
  1021.     {
  1022.                  fl = IT_SUPER_NAILGUN;
  1023.                  if (self.ammo_nails < 2)
  1024.                         am = 1;
  1025.     }
  1026. //======================================================================
  1027. //                      FLARE START
  1028. //========================================================================
  1029.     else if (self.impulse == 6)
  1030.     {
  1031.                 if (self.weapon == IT_GRENADE_LAUNCHER)
  1032.                 {
  1033.                         fl = IT_FLARE;
  1034.                         if (self.ammo_rockets < 1)
  1035.                                 am = 1;
  1036.                 }
  1037.                 else
  1038.                 {
  1039.                         fl = IT_GRENADE_LAUNCHER;
  1040.                         if (self.ammo_rockets < 1)
  1041.                                 am = 1;
  1042.                 }
  1043.     }
  1044. //=======================================================================
  1045. //                      FLARE END
  1046. //========================================================================
  1047.  
  1048.     else if (self.impulse == 7)
  1049.     {
  1050.                 fl = IT_ROCKET_LAUNCHER;
  1051.                 if (self.ammo_rockets < 1)
  1052.                         am = 1;       
  1053.     }
  1054.     else if (self.impulse == 8)
  1055.     {
  1056.         fl = IT_LIGHTNING;
  1057.         if (self.ammo_cells < 1)
  1058.             am = 1;
  1059.     }
  1060.               
  1061.      self.impulse = 0;
  1062.     
  1063.     if (!(self.items & fl))
  1064.     {    // don't have the weapon or the ammo
  1065.         sprint (self, "no weapon.\n");
  1066.         return;
  1067.     }
  1068.     
  1069.     if (am)
  1070.     {    // don't have the ammo
  1071.         sprint (self, "not enough ammo.\n");
  1072.         return;
  1073.     }
  1074.  
  1075. //
  1076. // set weapon, set ammo
  1077. //
  1078.     self.weapon = fl;        
  1079.     W_SetCurrentAmmo ();
  1080. };
  1081.  
  1082. /*
  1083. ============
  1084. CheatCommand
  1085. ============
  1086. */
  1087.  
  1088. void() CheatCommand =
  1089. {
  1090.     if (deathmatch || coop)
  1091.         return;
  1092.  
  1093.     self.ammo_rockets = 100;
  1094.     self.ammo_nails = 200;
  1095.     self.ammo_shells = 100;
  1096.     self.items = self.items | 
  1097.         IT_AXE |
  1098.         IT_SHOTGUN |
  1099.         IT_SUPER_SHOTGUN |
  1100.         IT_NAILGUN |
  1101.         IT_SUPER_NAILGUN |
  1102.         IT_GRENADE_LAUNCHER |
  1103.         IT_ROCKET_LAUNCHER |
  1104.                 IT_KEY1 | IT_KEY2;
  1105.  
  1106.     self.ammo_cells = 200;
  1107.     self.items = self.items | IT_LIGHTNING;
  1108.  
  1109.     self.weapon = IT_ROCKET_LAUNCHER;
  1110.     self.impulse = 0;
  1111.     W_SetCurrentAmmo ();
  1112. };
  1113.  
  1114.  
  1115.  
  1116. /*
  1117. ============
  1118. CycleWeaponCommand
  1119.  
  1120. Go to the next weapon with ammo
  1121. ============
  1122. */
  1123. void() CycleWeaponCommand =
  1124. {
  1125.     local    float    it, am;
  1126.     
  1127.     it = self.items;
  1128.     self.impulse = 0;
  1129.     
  1130.     while (1)
  1131.     {
  1132.         am = 0;
  1133.  
  1134.         if (self.weapon == IT_LIGHTNING)
  1135.         {
  1136.             self.weapon = IT_AXE;
  1137.         }
  1138.         else if (self.weapon == IT_AXE)
  1139.         {
  1140.             self.weapon = IT_SHOTGUN;
  1141.             if (self.ammo_shells < 1)
  1142.                 am = 1;
  1143.         }
  1144.         else if (self.weapon == IT_SHOTGUN)
  1145.         {
  1146.             self.weapon = IT_SUPER_SHOTGUN;
  1147.             if (self.ammo_shells < 2)
  1148.                 am = 1;
  1149.         }        
  1150.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1151.         {
  1152.             self.weapon = IT_NAILGUN;
  1153.             if (self.ammo_nails < 1)
  1154.                 am = 1;
  1155.         }
  1156.         else if (self.weapon == IT_NAILGUN)
  1157.         {
  1158.             self.weapon = IT_SUPER_NAILGUN;
  1159.             if (self.ammo_nails < 2)
  1160.                 am = 1;
  1161.         }
  1162.         else if (self.weapon == IT_SUPER_NAILGUN)
  1163.         {
  1164.                         self.weapon = IT_GRENADE_LAUNCHER;
  1165.             if (self.ammo_rockets < 1)
  1166.                 am = 1;
  1167.         }
  1168. //============================================================
  1169. //                      FLARE START
  1170. //============================================================
  1171.  
  1172.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1173.         {
  1174.                         self.weapon = IT_FLARE;
  1175.             if (self.ammo_rockets < 1)
  1176.                 am = 1;
  1177.         }
  1178.                 else if (self.weapon == IT_FLARE)
  1179.                 {
  1180.                         self.weapon = IT_ROCKET_LAUNCHER;
  1181.                         if (self.ammo_rockets < 1)
  1182.                                 am = 1;
  1183.                 }
  1184. //============================================================
  1185. //                              FLARE END
  1186. //============================================================
  1187.  
  1188.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1189.         {
  1190.             self.weapon = IT_LIGHTNING;
  1191.             if (self.ammo_cells < 1)
  1192.                 am = 1;
  1193.         }
  1194.  
  1195.         if ( (self.items & self.weapon) && am == 0)
  1196.         {
  1197.             W_SetCurrentAmmo ();
  1198.             return;
  1199.         }
  1200.     }
  1201.  
  1202. };
  1203.  
  1204. /*
  1205. ============
  1206. ServerflagsCommand
  1207.  
  1208. Just for development
  1209. ============
  1210. */
  1211. void() ServerflagsCommand =
  1212. {
  1213.     serverflags = serverflags * 2 + 1;
  1214. };
  1215.  
  1216. void() QuadCheat =
  1217. {
  1218.     if (deathmatch || coop)
  1219.         return;
  1220.     self.super_time = 1;
  1221.     self.super_damage_finished = time + 30;
  1222.     self.items = self.items | IT_QUAD;
  1223.     dprint ("quad cheat\n");
  1224. };
  1225.  
  1226. /*
  1227. ============
  1228. ImpulseCommands
  1229. ============
  1230. */
  1231. void() ImpulseCommands =
  1232. {
  1233.         if (self.impulse >= 1 && self.impulse <= 8)
  1234.         W_ChangeWeapon ();
  1235.  
  1236.     if (self.impulse == 9)
  1237.         CheatCommand ();
  1238.     if (self.impulse == 10)
  1239.         CycleWeaponCommand ();
  1240.     if (self.impulse == 11)
  1241.         ServerflagsCommand ();
  1242.  
  1243.  
  1244. //============================================================
  1245. //                      FLAME START
  1246. //============================================================
  1247.         if (self.impulse == 128)
  1248.                 PlugSelf();
  1249. //============================================================
  1250. //                      FLAME END
  1251. //============================================================
  1252.  
  1253.  
  1254. // *************************************************************************
  1255. // **                                          **
  1256. // ** M U L T I S K I N  1.1  (start)                                     **
  1257. // **                                      **
  1258. // *************************************************************************
  1259.  
  1260.  
  1261.     if ((self.impulse == 200) || (self.impulse == 201))
  1262.     {
  1263.         if (self.impulse == 200)
  1264.         {
  1265.         self.skin = self.skin + 1;
  1266.         if (self.skin == 19) self.skin = 0;
  1267.         } else
  1268.         if (self.impulse == 201)
  1269.         {
  1270.         self.skin = self.skin - 1;
  1271.         if (self.skin == -1) self.skin = 18;
  1272.         }
  1273.         if (self.skin == 0) centerprint(self, "SKIN: Quake himself (1)"); else
  1274.         if (self.skin == 1) centerprint(self, "SKIN: Duke Nukem 3d (2)"); else
  1275.         if (self.skin == 2) centerprint(self, "SKIN: Mr. Toad (3)"); else
  1276.         if (self.skin == 3) centerprint(self, "SKIN: the Stormtrooper (4)"); else
  1277.         if (self.skin == 4) centerprint(self, "SKIN: Max (5)"); else
  1278.         if (self.skin == 5) centerprint(self, "SKIN: the Terminator (6)"); else
  1279.         if (self.skin == 6) centerprint(self, "SKIN: Judge Dredd (7)"); else
  1280.         if (self.skin == 7) centerprint(self, "SKIN: Camouflaged soldier (8)"); else
  1281.         if (self.skin == 8) centerprint(self, "SKIN: Captain Picard (9)"); else
  1282.         if (self.skin == 9) centerprint(self, "SKIN: the Wizzard (10)"); else
  1283.         if (self.skin == 10) centerprint(self,"SKIN: the Predator (11)"); else
  1284.         if (self.skin == 11) centerprint(self,"SKIN: Skeleton (12)"); else
  1285.         if (self.skin == 12) centerprint(self,"SKIN: Wan-Fu (13)"); else
  1286.         if (self.skin == 13) centerprint(self,"SKIN: Henry Rollins (14)"); else
  1287.         if (self.skin == 14) centerprint(self,"SKIN: He-Man (15)"); else
  1288.         if (self.skin == 15) centerprint(self,"SKIN: Boba (16)"); else
  1289.         if (self.skin == 16) centerprint(self,"SKIN: Superman (17)"); else
  1290.         if (self.skin == 17) centerprint(self,"SKIN: NYPD Cop (18)"); else
  1291.         if (self.skin == 18) centerprint(self,"SKIN: Red/Yellow women dude (19)");
  1292.     }
  1293.  
  1294. // *************************************************************************
  1295. // **                                          **
  1296. // ** M U L T I S K I N  1.1  (end)                                       **
  1297. // **                                      **
  1298. // *************************************************************************
  1299.  
  1300.  
  1301.     if (self.impulse == 255)
  1302.         QuadCheat ();
  1303.         
  1304.     self.impulse = 0;
  1305. };
  1306.  
  1307. /*
  1308. ============
  1309. W_WeaponFrame
  1310.  
  1311. Called every frame so impulse events can be handled as well as possible
  1312. ============
  1313. */
  1314. void() W_WeaponFrame =
  1315. {
  1316.     if (time < self.attack_finished)
  1317.         return;
  1318.  
  1319.     ImpulseCommands ();
  1320.     
  1321. // check for attack
  1322.     if (self.button0)
  1323.     {
  1324.         SuperDamageSound ();
  1325.         W_Attack ();
  1326.     }
  1327. };
  1328.  
  1329. /*
  1330. ========
  1331. SuperDamageSound
  1332.  
  1333. Plays sound if needed
  1334. ========
  1335. */
  1336. void() SuperDamageSound =
  1337. {
  1338.     if (self.super_damage_finished > time)
  1339.     {
  1340.         if (self.super_sound < time)
  1341.         {
  1342.             self.super_sound = time + 1;
  1343.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1344.         }
  1345.     }
  1346.     return;
  1347. };
  1348.  
  1349.  
  1350.